﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Rainy.FrameWork;


namespace Admin.Register.RegFee
{
    public partial class RegFee_List : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                LoadListData();
            }
        }

        /// <summary>
        /// 列表数据加载
        /// </summary>
        private void LoadListData()
        {
            pagingControl.OnlyField = "PET_REGINFO_ID";                 //主ID
            pagingControl.OrderSyntax = " ORDER BY CREATE_TIME desc";   //排序条件
            pagingControl.TableName = "V_PET_REGINFO";                  //表名：T_PET_REGINFO（注册信息表）
            pagingControl.InstanceName = WebConfig.DataInstance;
            pagingControl.ProcedureName = "COMMON_PAGING";              //分页（存储过程）
            pagingControl.Condition = GetCondition();                   //查询条件

            DataTable dt = pagingControl.GetDataSet().Tables[0];
            this.gvInfo.DataSource = dt;
            this.gvInfo.DataBind();
        }

        /// <summary>
        /// 查询条件
        /// </summary>
        /// <returns></returns>
        private string GetCondition()
        {
            string condition = "1=1";
            //受理号
            if (this.txtAccept_No.Value.Trim() != string.Empty)
            {
                condition += " AND ACCEPT_NO like '%" + txtAccept_No.Value.Trim().Replace("'", "‘") + "%'";
            }
            //收费状态
            if (this.dprlCharge_State.SelectedValue != string.Empty)
            {
                condition += " AND CHARGE_STATE= '" + dprlCharge_State.SelectedItem.Text + "'";
            }
            //申请人
            if (this.txtRegister_Name.Value.Trim() != string.Empty)
            {
                condition += " AND REGISTER_NAME like '%" + txtRegister_Name.Value.Trim().Replace("'", "‘") + "%'";
            }
            //受理类型
            if (this.dprlAccept_type.SelectedValue != string.Empty)
            {
                condition += " AND ACCEPT_TYPE= '" + dprlAccept_type.SelectedItem.Text + "'";
            }
            //受理日期
            if (this.txtStartTime.Value.Trim() != "")
            {
                condition += " AND CREATE_TIME >=to_date('" + this.txtStartTime.Value.Trim() + "','yyyy-MM-dd')";
            }
            if (this.txtEndTime.Value.Trim() != "")
            {
                condition += " AND CREATE_TIME <=to_date('" + this.txtEndTime.Value.Trim() + "','yyyy-MM-dd')";
            }
            //发票号
            if (this.txtReceipt_No.Value.Trim() != string.Empty)
            {
                condition += " AND RECEIPT_NO like '%" + txtReceipt_No.Value.Trim().Replace("'", "‘") + "%'";
            }
            return condition;
        }

        /// <summary>
        /// 分页事件
        /// </summary>
        protected void pagingControl_PageChanged()
        {
            LoadListData();
        }

        /// <summary>
        /// 查询事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            LoadListData();
        }

        /// <summary>
        /// 获取受理类型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetAcceptType(string strID)
        {
            string strReturn = "";
            switch (strID)
            {
                case "1":
                    strReturn = "个人";
                    break;

                case "2":
                    strReturn = "单位";
                    break;
            }
            return strReturn;
        }

        /// <summary>
        /// 获取收费状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetCardType(string strID)
        {
            string strReturn = "";
            switch (strID)
            {
                case "N":
                    strReturn = "未收费";
                    break;

                case "Y":
                    strReturn = "已收费";
                    break;
            }
            return strReturn;
        }
    }
}